home *** CD-ROM | disk | FTP | other *** search
- Path: nntp.teleport.com!usenet
- From: GHouck <hksys@teleport.com>
- Newsgroups: comp.lang.c
- Subject: Re: void test(...)
- Date: 20 Mar 1996 09:23:18 GMT
- Organization: systems hk
- Message-ID: <4ioiq6$6nd@nadine.teleport.com>
- References: <4if00v$hdk@news.NetVision.net.il>
- NNTP-Posting-Host: ip-pdx03-24.teleport.com
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 1.22 (Windows; I; 32bit)
-
- nir@netvision.net.il (Nir Sofer) wrote:
- >I know that i can create in C a function with variable number of arguments.
- >
- >void test(...)
- >{
- >}
- >
- >But i can i use these arguments ???
- >
- >Nir Sofer
- >nir@netvision.net.il
- >
- Nir,
-
- I use the following to output to a file without having to open
- the file each time. It is basically like 'printf' (which has
- variable arguments) with the first argument the name of the
- file I am writing to.
-
- /*----------------------------------------------------------------------+
- | FLP - output log messages. Opens/closes the logfile before/after
- | each write
- +----------------------------------------------------------------------*/
- int FLP ( char *file, char *fmt, ... )
- {
- FILE *strm;
- va_list argptr;
- int cnt;
-
- strm = fopen( file,"a+" );
- if( !strm )
- strm = fopen( file,"w" );
- if( !strm )
- return( 0 );
- va_start( argptr,fmt );
- cnt = vfprintf( strm,fmt,argptr );
- va_end( argptr );
-
- fclose( strm );
-
- return( cnt );
- }
-
-
-